/*计算100以内的累加和、奇数和和偶数和*/
public class sum100 {
    public static void main(String[] args){
        /*int sum = 0;
        for (int i = 0;i<=100;i++){
            sum = sum +i;
        }System.out.println("1到100的和为："+sum);

        int sum1 = 0;
        for (int a = 100 ; a>0;a-=2){
            sum1 = sum1 + a;
        }System.out.println("1到100内的偶数和为："+sum1);

        int sum2 = 0;
        for (int b = 99 ; b>0;b-=2){
            sum2 = sum2 + b;
        }System.out.println("1到100内的奇数和为："+sum2);*/

        int sum = 0;
        int oddsum = 0;//奇数和
        int evensum = 0;//偶数和
        for (int i = 0;i<=100;i++){
            sum+=i;
            if (i%2==0){
                evensum+=i;
            }else {
                oddsum+=i;
            }
        }System.out.println("总和为："+sum);
        System.out.println("奇数和为："+oddsum);
        System.out.println("偶数和为："+ evensum);
    }
}
